<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>Ajax.html</title>

		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="this is my page">
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">

		<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
		<script type="text/javascript">

var xmlHttpRequest;

function getResult() {

	var text1 = document.getElementById("text1").value;
	var text2 = document.getElementById("text2").value;
	if (window.ActiveXObject) {
		xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
	} else if (window.XMLHttpRequest) {
		xmlHttpRequest = new XMLHttpRequest();
	}

	alert(text1);
	alert(text2);
	
	if (xmlHttpRequest) {
		xmlHttpRequest.open("GET", "AjaxServlet?text1=" + text1 + "&text2="
				+ text2, true);
		xmlHttpRequest.onreadystatechange = ajaxCallBack;

		xmlHttpRequest.send(null);
	}
}

function ajaxCallBack() {
	if (xmlHttpRequest.readyState == 4) {
		if (xmlHttpRequest.status == 200) {
			var responseTest = xmlHttpRequest.responseText;
			document.getElementById("result").innerHTML = responseTest;
		}
	}
}
</script>
	</head>

	<body>
		<input type="text" id="text1" />
		+
		<input type="text" id="text2" />
		=
		<span id="result"></span>
		<br />
		<input type="button" value="submit" onclick="getResult();" />
		<br>
	</body>
</html>
